{% extends "background/base.html" %}
{% block pagetitle %}: 内容替换: 替换章节{% endblock %}
{% block content %}
  <div id="NAVID" data-nav="replace"></div>
  <div class="row">
    <div class="col-xs-12">
      <div class="panel panel-primary">
        <div class="panel-heading">替换章节</div>
        <div class="panel-body">
          <form action="." method="POST" class="form-inline">{% csrf_token %}
          {% with create_rule_form as CRF %}
            <div class="form-group {%if CRF.rule_res.errors%}has-error{%endif%}">
              <label for="inputRe" class="sr-only control-label">{{CRF.rule_res.label}}</label>
              <input
                placeholder="{{CRF.rule_res.label}}"
                type="text"
                value="{{CRF.rule_res.value|default:''}}"
                name="rule_res"
                class="form-control"/>
            </div>
            <div class="form-group {%if CRF.replace_to.errors%}has-error{%endif%}">
              <label for="inputReplace" class="sr-only control-label">{{CRF.replace_to.label}}</label>
              <input
                placeholder="{{CRF.replace_to.label}}"
                type="text"
                value="{{CRF.replace_to.value|default:''}}"
                name="replace_to"
                class="form-control"/>
            </div>
            <div class="form-group {%if CRF.page_number.errors%}has-error{%endif%}">
              <label for="inputReplace" class="sr-only control-label">{{CRF.page_number.label}}</label>
              <input
                placeholder="{{CRF.page_number.label}}"
                type="text"
                value="{{CRF.page_number.value|default:''}}"
                name="page_number"
                class="form-control"/>
            </div>
            <div style="display: inline;" class="radio radio-primary page-radio">
              {% for radio in CRF.p_or_s %}{{radio}}
              {% endfor %}
            </div>
            <button type="submit" class="btn btn-success btn-sm btn-raised">提交</button>
          {% endwith %}
          </form>
        </div>
      </div>
    </div>
    {% if save %}
      <div class="col-xs-12">
        <div class="alert alert-warning text-center">
          <h2>保存成功!</h2>
        </div>
      </div>
    {% endif %}
    {% if content or r_content %}
      <div class="col-xs-12">
        <div class="panel panel-primary">
          <div class="panel-heading">预览</div>
          <div class="panel-body">
            <div class="row">
              <div class="col-xs-6">
                <div class="panel panel-primary">
                  <div class="panel-heading">
                    <h3 class="panel-title">原文</h3>
                  </div>
                  <div class="panel-body">{{content|safe|linebreaks}}
                  </div>
                </div>
              </div>
              <div class="col-xs-6">
                <div class="panel panel-primary">
                  <div class="panel-heading">
                    <h3 class="panel-title">替换后</h3>
                  </div>
                  <div class="panel-body">{{r_content|safe|linebreaks}}
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    {% endif %}
  </div>
{% endblock %}
